#include <iostream>
#include <stack>
using namespace std;

stack<int> a, b;
int n, cnt;
size_t m;

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int input;
        cin >> input;
        if (a.empty() || a.top() > input)
        {
            a.push(input);
        }
        else
        {
            if (b.empty() || b.top() < input)
            {
                b.push(input);
            }
            else
            {
                m = max(m, a.size());
                cnt++;
                while (!a.empty())
                {
                    a.pop();
                }
                while (!b.empty() && b.top() > input)
                {
                    a.push(b.top());
                    b.pop();
                }
                a.push(input);
            }
        }
    }
    if (!a.empty())
    {
        cnt++;
        m = max(m, a.size());
    }
    if (!b.empty())
    {
        cnt++;
        m = max(m, b.size());
    }
    cout << cnt << " " << m;
    return 0;
}